<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="org.springframework.web.context.WebApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="db.UserDAO"%>
<%@page import="db.User"%>
<%@page import="db.AuthorityDAO"%>
<%@page import="db.Authority"%>
<%@ include file="/jsp/common/utility/logined.jsp" %>
<%
	WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
	UserDAO userDao = (UserDAO)ctx.getBean("UserDAO");
	AuthorityDAO authorityDao = (AuthorityDAO)ctx.getBean("AuthorityDAO");

	String uid_str = (String)request.getParameter("uid");
	
	Integer uid_int = Integer.parseInt(uid_str);
	User user = userDao.findById(uid_int);
	if(user != null){
		request.setAttribute("user",user);
		
		List list = authorityDao.findByUserId(uid_int);
		Map map = new HashMap();
		for(int i=0;i<list.size();i++){
			Authority authority = (Authority)list.get(i);
			String model = authority.getModule1() + "-" + authority.getModule2();
			map.put(authority.getModule1() + "",authority.getModule1());
			map.put(authority.getModule1() + "-" + authority.getModule2(),1);
		}
		request.setAttribute("authMap",map);
		
		pageContext.forward("/vm/erp_tpl/modPer.vm");
	}else{
		pageContext.forward("/index.jsp");
	}
%>
